
/**
 * @author murugan.kannan
 *
 */
public class Vector2D {
	
	double x, y, theta = 0.0;
	Vector2D unit;

	public Vector2D(double x, double y) {
		this.x = x;
		this.y = y;
	}

	public Vector2D() {
	}

	public double dot(Vector2D vec2) {
		return this.x * vec2.x + this.y * vec2.y;
	}

	public Vector2D add(Vector2D vec2) {
		Vector2D res = new Vector2D();
		res.x = this.x + vec2.x;
		res.y = this.y + vec2.y;
		return res;
	}

	public Vector2D sub(Vector2D vec2) {
		Vector2D res = new Vector2D();
		res.x = this.x - vec2.x;
		res.y = this.y - vec2.y;
		return res;
	}

	public double mod() {

		return Math.sqrt(this.x * this.x + this.y * this.y);
	}
	
	public void incmod(double speed){
		double mod=mod();
		mod+=speed;
		x=mod*Math.cos(Math.toRadians(theta));
		y=mod*Math.sin(Math.toRadians(theta));
		System.out.println(x+" "+y+" "+mod);
	}
	

	public double angle() {
		double val = y / mod();
		theta = Math.toDegrees(Math.asin(val));
		return theta;
	}

	public void print() {
		System.out.println(x + "i + " + y + "j");
		System.out.println(angle());
		System.out.println(mod());

	}
}
